/***************************************************************
****************************************************************
*****  Language for Parallel Management of External Devices*****
****************************************************************
***************************************************************/

lexer grammar LPMEDLexer;
options
{
    language = CSharp2;
}

tokens{ CPROGRAM;
    CDEVICE;
    CTYPE;      // objavlenie peremennoj
    CBLOCK;     // blok koda
    CSTATEMENT; // sostvnoj operator
    CIFTE;      // if-then-else
    CASSIGN;    // prisvaivanije
    CWHILE;
    CFOR;
    CFORDEC;
    CUNARMIN;
    CMETHODNAME;
    CCALL;        // any state transition \ method execution
    CINT;
    CFLOAT;
    CBOOL;
        CSYNCCALL;   // sunchronous state transition \ method execution
        CASYNCCALL;  // asunchronous state transition \ method execution
        CWAITTHECALL; // wait for completition of the asunchronous state transition \ method execution
        CWAITANYCALL; // wait for completition of any asunchronous state transition \ method execution
        CENDTHECALL;         // reset pressure
        OBJECTNAME;   //Name of device (or any object for future using)
        MEMBERNAME;
        NODES;        //Nodes of Device
    CGETSTATE;      //Get state of device
    

    CBREAKPOINT; //Break point ;)

    CREGMETHACCESS; //Access to the method (signature: object->void) of CLR-object, registered in Lua
    CREGFUNCACCESS; //Access to the function (signature: void->object) of CLR-object, registered in Lua
    
    CTERMINATEALL;
    
    //functions
    CASYNCFUNCCALL;
    CSYNCFUNCCALL;
    CWAITFUNCFINISH;
    CDEFUN; //new function definition
    
    PARAMS; //parameterlist
    PARAM; //one parameter
}

@namespace { Core.ANTLRGrammars }

TERMINATEALL    : 'terminate_all';

OpIncDec    : '++'|'--';
OpNegation  : '!'|'not';
OpUnar      : '-';
OpDivMul    : '*'|'/';
OpAddSub    : '+'|'-';
OpLogicalA  : '<'|'<='|'>'|'>=';
OpLogicalB  : '=='|'~=';
OpAnd       : '&&'|'and';
OpOr        : '||'|'or';

TYPE    :   
        'int'
    |   'float'
    |   'bool'
    |   'string'
    ;

DBOOL   :
        'true'
    |   'false'
    ;

DEVICE  :   'DEVICE';

STATE   : 'State';

ENDDEVICE
    : 
        ('END' '.')
    ;

INT     :   
        ('0'..'9')+ 
    ;

FLOAT   :
        INT '.' INT
    ;

IF : 'if';
THEN : 'then';
ELSE : 'else';
FOR : 'for';
WHILE : 'while';
WAIT  : 'wait';
GO    : 'go';
ENDPRESSURE:'end';
VAR : 'VAR';

BREAKPOINT: 'Breakpoint' ;

DEFUN: 'defun';

WS      :   (   ' '
            |   '\t'
            |   '\r'
            |   '\n'
            )+
            { $channel=HIDDEN; }
        ;


fragment NEWLINE:   '\r'|'\n'
;

LINECOMMENT :   '//' ~('\r'|'\n')* NEWLINE {$channel=HIDDEN;}
;

ID      :   ('a'..'z' | 'A'..'Z' | '_') ('a'..'z' | 'A'..'Z' | '0'..'9' | '_')*;

OBRACKET    : '(';

CBRACKET    : ')';

CURLYOBRACKET   : '{';

CURLYCBRACKET   : '}';

EQUALS      : '=';

DOT     : '.';

SEMI        : ';';

COLON       : ':';

COMMA       : ',';